Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Remove the dependency on cluster-api/utils from addons API #9482

Merged

Conversation

killianmuldoon
Copy link
Contributor

@killianmuldoon killianmuldoon commented Sep 21, 2023

Remove the dependency on cluster-api/util from the addons API package. This removes a large set of dependencies for importers of that API.

Part of #9011

/area api

@k8s-ci-robot k8s-ci-robot added area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 21, 2023
// removeOwnerRef returns the slice of owner references after removing the supplied owner ref.
// Note: removeOwnerRef ignores apiVersion and UID. It will remove the passed ownerReference where it matches Name, Group and Kind.
//
// Deprecated: This function is deprecated and will be removed in an upcoming release of Cluster API.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied these functions over from the util package. We only have to keep them until the next release and then we can remove these funtions.

@@ -196,7 +196,12 @@ func (r *ClusterResourceSetReconciler) reconcileDelete(ctx context.Context, clus
return err
}

clusterResourceSetBinding.DeleteBinding(crs)
clusterResourceSetBinding.RemoveBinding(crs)
clusterResourceSetBinding.OwnerReferences = util.RemoveOwnerRef(clusterResourceSetBinding.GetOwnerReferences(), metav1.OwnerReference{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the ownerReferences handling into the controller which makes more sense to me and means we don't have to keep a copy of the ownerRef handling code in the addons v1beta1 package.

@killianmuldoon
Copy link
Contributor Author

@JoelSpeed I think this should cut down the import list of the addons package.

Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

One question though, how do we prevent regressions of the transitive deps in the API repos? Can the import restrictions tool look at transitive dependencies at all?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 21, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ba3dc5bfc537164131a50df5a2bebc9b497f52c9

@JoelSpeed
Copy link
Contributor

@killianmuldoon

This should hopefully prevent the transitive dependencies coming back once this PR is merged, PTAL

@sbueringer
Copy link
Member

sbueringer commented Sep 21, 2023

@killianmuldoon

This should hopefully prevent the transitive dependencies coming back once this PR is merged, PTAL

One way we could do this is to have a "verification go module" in our repo just like the one you have.

  • create a separate go module
  • have imports to all our API packages
  • include it in generate-modules / verify-modules so it's always up-to-date (as that's run in our verify presubmit)
  • add a verify target to ensure there is no "controller-runtime" in the go.mod file

(I hope it works with relative require statements in go.mod)

Maybe a bit hacky, but maybe not too bad and good enough for what we want (and it basically simulates 100% e2e what we want to ensure / what users end up with)

@JoelSpeed
Copy link
Contributor

Yeah adding a verification module could work, but you're right it's a bit hacky. I wonder if there's a way to extend the import boss tool to verify dependent modules as well. Will do a bit of research

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding a new .import-restrictions file?

}
}

// TODO(killianmuldoon): Remove this code in a future release. This is now duplicated in the controller.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not already removing it now (only for this new function) when already introducing a new function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that - it was from me going over and back on how to handle the deprecation 🤦

@killianmuldoon killianmuldoon force-pushed the pr-remove-util-dep-addons branch from ec26284 to 3b9b48b Compare September 25, 2023 14:26
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 25, 2023
@killianmuldoon
Copy link
Contributor Author

Worth adding a new .import-restrictions file?

I think it would be better to try to pursue something which can catch indirect dependencies - otherwise we'll have a mess of restrictions across the codebase IMO.

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 25, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: fdf5b7c8bcb6ba82e009b377a3c597e249dcb7e5

Copy link
Contributor Author

@killianmuldoon killianmuldoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: killianmuldoon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 26, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3094909 into kubernetes-sigs:main Sep 26, 2023
13 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.6 milestone Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants